package com.lin.baby.boot.chapter1.service.impl;

import com.lin.baby.boot.chapter1.service.CallSayHelloService;
import com.lin.baby.boot.chapter1.service.HelloService;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * 调用sayHelloService
 *
 * @author WangYang
 * @version 1.0
 * @datetime 2016/10/13 16:34
 */
@Service("callSayHelloService")
public class CallSayHelloServiceImpl implements CallSayHelloService {

    @Resource
    private HelloService helloService;

    @PostConstruct
    private void init() {
        System.out.println("(注解方式)构造函数执行后处理：" + CallSayHelloServiceImpl.class.getName());
    }

    @Override
    public void callSayHello(String word) {
        System.out.println(helloService.sayHello(word));
    }

    @PreDestroy
    private void destroy() {
        System.out.println("(注解方式)销毁之前处理：" + CallSayHelloServiceImpl.class.getName());
    }
}
